<?php

require_once ('common.php');
$action = trim($_REQUEST['action']);
$template = 'home.html';
$pageid = 'home';
$pagetitle = 'หน้าแรก';
$currentPage = empty($_GET['page']) ? 0 : (int)$_GET['page'] - 1;
if ($action == 'newtopic')
{
    checkLogin();
    $emos = $bbcode->getEmos();
    $icons = getIcons();
    $pageid = 'newtopic';
    $template = 'newtopic.html';
    $pagetitle = 'ตั้งกระทู้';
}
$pages = getPages($currentPage);
$topics = getAllTopics($currentPage);
$smarty->assign('pageid', $pageid);
$smarty->assign('pagetitle', $pagetitle);
$smarty->display('header.html');
$smarty->assign('pages', $pages);
$smarty->assign('topics', $topics);
$smarty->assign('emos', $emos);
$smarty->assign('icons', $icons);
$smarty->display($template);
require_once ('sidebar.php');
require_once ('footer.php');

?>